package com.dwx.shopping_mall.controller;

import com.dwx.shopping_mall.entity.Wallet;
import com.dwx.shopping_mall.service.WalletService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/wallet")
public class WalletController {

    @Autowired
    private WalletService walletService;

    /**
     * 查看钱包
     * @param userId
     * @return
     */
    @GetMapping("/queryWallet")
    public Wallet queryWallet(Integer userId){
        return walletService.queryWallet(userId);
    }

    /**
     * 开通钱包服务
     * @param userId
     * @param status
     * @return
     */
    @PostMapping("/openWalletServer")
    public int activateWallet(Integer userId,int status) {
        return walletService.openWallet(userId,status);
    }

    /**
     * 更新钱包状态（激活，关闭）
     * @param userId
     * @param status
     * @return
     */
    @PutMapping("/updateWalletStatus")
    public int updateWalletStatus(Integer userId, int status){
        return walletService.updateWalletStatus(userId,status);
    }


}
